package com.kfh.ybracelet.bean;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * Created by Aaron on 16/1/19.
 */
public class SearchContract implements Parcelable {

    public UserInfoEntity userInfo;
    public boolean isFriend;
    public int code;
    public String code_msg;

    public static class UserInfoEntity implements Parcelable {

        public String nickName;
        public String imgUrl;
        public String phoneNum;

        @Override
        public int describeContents() {
            return 0;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            dest.writeString(this.nickName);
            dest.writeString(this.imgUrl);
            dest.writeString(this.phoneNum);
        }

        public UserInfoEntity() {
        }

        protected UserInfoEntity(Parcel in) {
            this.nickName = in.readString();
            this.imgUrl = in.readString();
            this.phoneNum = in.readString();
        }

        public static final Parcelable.Creator<UserInfoEntity> CREATOR = new Parcelable.Creator<UserInfoEntity>() {
            public UserInfoEntity createFromParcel(Parcel source) {
                return new UserInfoEntity(source);
            }

            public UserInfoEntity[] newArray(int size) {
                return new UserInfoEntity[size];
            }
        };
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeParcelable(this.userInfo, 0);
        dest.writeByte(isFriend ? (byte) 1 : (byte) 0);
        dest.writeInt(this.code);
        dest.writeString(this.code_msg);
    }

    public SearchContract() {
    }

    protected SearchContract(Parcel in) {
        this.userInfo = in.readParcelable(UserInfoEntity.class.getClassLoader());
        this.isFriend = in.readByte() != 0;
        this.code = in.readInt();
        this.code_msg = in.readString();
    }

    public static final Parcelable.Creator<SearchContract> CREATOR = new Parcelable.Creator<SearchContract>() {
        public SearchContract createFromParcel(Parcel source) {
            return new SearchContract(source);
        }

        public SearchContract[] newArray(int size) {
            return new SearchContract[size];
        }
    };
}
